#!/bin/bash
# This script load/unload clx kernel modules

### BEGIN INIT INFO
# Provides:          load-clx-modules
# Required-Start:
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Load clx kernel modules
### END INIT INFO

case "$1" in
start)
        echo -n "Load clx kernel modules... "

        RMEM_SIZE=`cat /proc/sys/net/core/rmem_max`
        if [ $RMEM_SIZE -lt 8388608 ]; then
            echo "8388608" > /proc/sys/net/core/rmem_max
        fi
        WMEM_SIZE=`cat /proc/sys/net/core/wmem_max`
        if [ $WMEM_SIZE -lt 25165824 ]; then
            echo "25165824" > /proc/sys/net/core/wmem_max
        fi

        if ! modprobe clx_dev ; then
            modprobe nps_dev
        fi
        if ! modprobe clx_netif ; then
            modprobe nps_netif
        fi

        echo "done."
        ;;

stop)
        echo -n "Unload clx kernel modules... "

        if ! rmmod clx_netif ; then
            rmmod nps_netif
        fi
        if ! rmmod clx_dev ; then
            rmmod nps_dev
        fi

        echo "done."
        ;;

force-reload|restart)
        echo "Not supported"
        ;;

*)
        echo "Usage: /etc/init.d/clx-modules {start|stop}"
        exit 1
        ;;
esac

exit 0

